****FIGURE 5****

cd "$main_dir/output/figures/main"

graph set window fontface "Palatino"

//--------------------------------------------------------
//Read in relevant datasets
//--------------------------------------------------------

clear
use "$data_dir/clean/country_year_cohort_panel.dta"
drop if cohort=="2000s"

//--------------------------------------------------------
//Create individual country charts
//--------------------------------------------------------

//GREECE
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="GRC" & survey_year==2019 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabposition(9) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="GRC" & survey_year==2019 & chrt_total>=50 & chrt_total!=., title(Greece, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(0.2(0.15)0.7,labs(small) format(%9.2f)) xlabel(0(0.008)0.018,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off) 
graph save "grc_cohort_2019.gph", replace

//JAPAN
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="JPN" & survey_year==2019 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="JPN" & survey_year==2019 & chrt_total>=50 & chrt_total!=., title(Japan, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(0.3(0.1)0.55,labs(small) format(%9.2f)) xlabel(0.01(0.005)0.025,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "jpn_cohort_2019.gph", replace

//SPAIN
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="ESP" & survey_year==2019 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="ESP" & survey_year==2019 & chrt_total>=50 & chrt_total!=., title(Spain, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(0.3(0.1)0.55,labs(small) format(%9.2f)) xlabel(0.01(0.01)0.03,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "esp_cohort_2019.gph", replace

//VENEZUELA
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="VEN" & survey_year==2019 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="VEN" & survey_year==2019 & chrt_total>=50 & chrt_total!=., title(Venezuela, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(,labs(small) format(%9.2f)) xlabel(-0.04(0.01)-0.008,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "ven_cohort_2019.gph", replace

gr combine grc_cohort_2019.gph jpn_cohort_2019.gph esp_cohort_2019.gph ven_cohort_2019.gph, graphregion(color(white)) col(4) title("Stagnation", color(black))
graph save "figure_5_stagnation.gph", replace

//CHINA
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="CHN" & survey_year==2018 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="CHN" & survey_year==2018 & chrt_total>=50 & chrt_total!=., title(China, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(,labs(small) format(%9.2f)) xlabel(0.05(0.005)0.066,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "chn_cohort_2018.gph", replace

//HONG KONG
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="HKG" & survey_year==2019 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="HKG" & survey_year==2019 & chrt_total>=50 & chrt_total!=., title("Hong Kong", color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(0(0.25)0.5,labs(small) format(%9.2f)) xlabel(0.0225(0.005)0.0325,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "hkg_cohort_2019.gph", replace

//SINGAPORE
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="SGP" & survey_year==2018 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="SGP" & survey_year==2018 & chrt_total>=50 & chrt_total!=., title(Singapore, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(0.88(0.04)1,labs(small) format(%9.2f)) xlabel(0.0375(0.005)0.049,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "sgp_cohort_2018.gph", replace

//TAIWAN
scatter trust_govt chrt_wgrowth_rate_1 if ccode=="TWN" & survey_year==2019 & chrt_total>=50 & chrt_total!=., mlabel(cohort) mlabcolor(black) xtitle(Average Lifetime Growth Experience) ytitle(Trust in Government) || lfit trust_govt chrt_wgrowth_rate_1 if ccode=="TWN" & survey_year==2019 & chrt_total>=50 & chrt_total!=., title(Taiwan, color(black)) ytitle(Trust in Government) graphregion(color(white)) bgcolor(white) ylabel(,labs(small) format(%9.2f)) xlabel(,labs(small)) xtitle("Growth Experience", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) legend(off)
graph save "twn_cohort_2019.gph", replace

gr combine chn_cohort_2018.gph hkg_cohort_2019.gph sgp_cohort_2018.gph twn_cohort_2019.gph, graphregion(color(white)) title("Growth", color(black)) col(4)
graph save "figure_5_growth.gph", replace

//--------------------------------------------------------
//Create Figure 5
//--------------------------------------------------------

gr combine figure_5_stagnation.gph figure_5_growth.gph, row(2) graphregion(color(white))
graph export "figure_5.png", replace
graph export "figure_5.tif", replace as(tif) width(3600)

erase "figure_5_stagnation.gph"
erase "figure_5_growth.gph"
erase "chn_cohort_2018.gph" 
erase "hkg_cohort_2019.gph"
erase "sgp_cohort_2018.gph" 
erase "twn_cohort_2019.gph"
erase "grc_cohort_2019.gph" 
erase "jpn_cohort_2019.gph" 
erase "esp_cohort_2019.gph" 
erase "ven_cohort_2019.gph"

